package cn.z2huo.knowledge.basic.bit.bitwiseoperation;

/**
 * <pre>
 * - 按位与
 * - 按位或
 * - 按位异或
 * </pre>
 *
 */
class AndOrBoolean {

	public static void main(String[] args) {

		System.out.println("布尔类型按位与");
		System.out.println(true & false);
		System.out.println(true & true);
		System.out.println(false & true);
		System.out.println(false & false);

		System.out.println("\n布尔类型按位或");
		System.out.println(true | false);
		System.out.println(true | true);
		System.out.println(false | true);
		System.out.println(false | false);

		System.out.println("\n布尔类型按位异或");
		System.out.println(true ^ false);
		System.out.println(true ^ true);
		System.out.println(false ^ true);
		System.out.println(false ^ false);

		System.out.println();
		boolean a = true;
		boolean b = false;
		boolean c;
		c = (a=(1==2)) && (b=(1==1));
		System.out.println(c);
		if(c) {
			System.out.println("逻辑与 短路");
		}
		System.out.println(a);
		System.out.println(b);
		
		if ((a=(1==2)) & (b=(1==1))) {
			System.out.println("按位与 无短路");
		}
		System.out.println(a);
		System.out.println(b);
	}
}
